# 启动节点

from launch import LaunchDescription
from launch_ros.actions import Node
import os
from ament_index_python.packages import get_package_share_directory

def generate_launch_description():
    # 获取包的共享目录
    package_name = 'rm_detector'  # 包名
    pkg_share = get_package_share_directory(package_name)

    # 发布节点
    img_publisher_node = Node(
        package=package_name,
        executable='publisher_node',  # 可执行文件
        name='image_publisher',  # 发布节点名称
        output='screen'
    )

    # 订阅节点
    img_subscriber_node = Node(
        package='rqt_image_view',
        executable='rqt_image_view',  # 可执行文件
        name='image_subscriber', # 订阅节点名称
        output='screen'
    )

    # 创建LaunchDescription对象并添加节点
    ld = LaunchDescription()
    ld.add_action(img_publisher_node)
    ld.add_action(img_subscriber_node)

    return ld